#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
主题: 只接受关键字参数的函数
问题: 你希望函数的某些参数强制使用关键字参数传递
提示 : 
    1. 强制关键字参数也会比使用**kwargs参数更好
"""

def recipe1():
    # recv(1024, True)      # TypeError
    recv(1024, block=True)  # ok

def recipe2():
    print(f"{minimum(1, 5, 2, -5, 10) = }")
    print(f"{minimum(1, 5, 2, -5, 10, clip = 0) = }")

def minimum(*values, clip=None):
    '''接受任意多个位置参数的函数中指定关键字参数'''
    m = min(values)
    if clip is not None:
        m = clip if clip > m else m
    return m

def recv(maxsize, *, block):
    'Receives a message'
    pass

def main():
    print('recipe1'.center(20, '*'))
    recipe1()
    print('recipe2'.center(20, '*'))
    recipe2()

if __name__ == '__main__':
    main()   